package com.zdy.im.common.exception;

import com.alibaba.fastjson.JSONObject;

import java.io.Serializable;

/**
 * @Author 作者 : zdy
 * @CreateDate 创建时间: 2021-02-30
 */
public class ResultBody<T> implements Serializable {

    public ResultBody(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public ResultBody(BaseErrorInfoInterface errorInfo) {
        this.code = errorInfo.getResultCode();
        this.message = errorInfo.getResultMsg();
    }

    public ResultBody(T result) {
        this.result = result;
    }

    /**
     * 返回消息代码 默认OK，错误自定义
     */
    private String code = "200";

    /**
     * 消息提醒内容
     */
    private String message;


    private T result;


    @Override
    public String toString() {
        return JSONObject.toJSONString(this);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }
}
